﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XmlStudio.Interfaces;

namespace XmlStudio.DataLayer {
    /// <summary>
    /// Helper class for xsd simpleTypes.
    /// </summary>
    public static class XsdAttributeFactory {
        /// <summary>
        /// Lists required simpleTypes for given element type.
        /// </summary>
        /// <param name="elementType">Element type.</param>
        /// <returns>Collection of required simpleTypes.</returns>
        public static IEnumerable<IBigXmlAttribute> ListRequiredAttributes(XsdElement elementType) {
            var list = new List<IBigXmlAttribute>();
            switch(elementType) {
                case XsdElement.All:
                    break;
                case XsdElement.Annotation:
                    break;
                case XsdElement.Any:
                    break;
                case XsdElement.AnyAttribute:
                    break;
                case XsdElement.AppInfo:
                    break;
                case XsdElement.Attribute:
                    break;
                case XsdElement.AttributeGroup:
                    break;
                case XsdElement.ComplexContent:
                    break;
                case XsdElement.ComplexType:
                    break;
                case XsdElement.Documentation:
                    break;
                case XsdElement.Element:
                    break;
                case XsdElement.Enumeration:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.Extension:
                    list.Add(new BigXmlAttribute("base", ""));
                    break;
                case XsdElement.Field:
                    list.Add(new BigXmlAttribute("xpath", ""));
                    break;
                case XsdElement.FractionDigits:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.Group:
                    break;
                case XsdElement.Choice:
                    break;
                case XsdElement.Import:
                    break;
                case XsdElement.Include:
                    list.Add(new BigXmlAttribute("schemaLocation", ""));
                    break;
                case XsdElement.Key:
                    list.Add(new BigXmlAttribute("name", ""));
                    break;
                case XsdElement.KeyRef:
                    list.Add(new BigXmlAttribute("name", ""));
                    list.Add(new BigXmlAttribute("refer", ""));
                    break;
                case XsdElement.Length:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.List:
                    // to do: itemType: Specifies the name of a built-in data type or simpleType element defined in this or another schema.
                    // This attribute is not allowed if the content contains a simpleType element, otherwise it is required
                    break;
                case XsdElement.MaxExclusive:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.MaxInclusive:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.MaxLength:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.MinExclusive:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.MinInclusive:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.MinLength:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.Notation:
                    list.Add(new BigXmlAttribute("name", ""));
                    list.Add(new BigXmlAttribute("public", ""));
                    break;
                case XsdElement.Pattern:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.Redefine:
                    list.Add(new BigXmlAttribute("schemaLocation", ""));
                    break;
                case XsdElement.Restriction:
                    list.Add(new BigXmlAttribute("base", ""));
                    break;
                case XsdElement.Selector:
                    list.Add(new BigXmlAttribute("xpath", ""));
                    break;
                case XsdElement.Sequence:
                    break;
                case XsdElement.Schema:
                    break;
                case XsdElement.SimpleContent:
                    break;
                case XsdElement.SimpleType:
                    // name: Specifies a name for the element. This attribute is required if the simpleType element is a child of the schema element, otherwise it is not allowed
                    break;
                case XsdElement.TotalDigits:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
                case XsdElement.Union:
                    break;
                case XsdElement.Unique:
                    list.Add(new BigXmlAttribute("name", ""));
                    break;
                case XsdElement.WhiteSpace:
                    list.Add(new BigXmlAttribute("value", ""));
                    break;
            }

            return list;
        }

        /// <summary>
        /// Lists optional simpleTypes for given element type.
        /// </summary>
        /// <param name="elementType">Element type.</param>
        /// <returns>Collection of optional simpleTypes.</returns>
        public static IEnumerable<IBigXmlAttribute> ListOptionalAttributes(XsdElement elementType) {
            var list = new List<IBigXmlAttribute>();
            switch(elementType) {
                case XsdElement.All:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("maxOccurs", ""));
                    list.Add(new BigXmlAttribute("minOccurs", ""));
                    break;
                case XsdElement.Annotation:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.Any:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("maxOccurs", ""));
                    list.Add(new BigXmlAttribute("minOccurs", ""));
                    list.Add(new BigXmlAttribute("namespace", ""));
                    list.Add(new BigXmlAttribute("processContents", ""));
                    break;
                case XsdElement.AnyAttribute:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("namespace", ""));
                    list.Add(new BigXmlAttribute("processContents", ""));
                    break;
                case XsdElement.AppInfo:
                    list.Add(new BigXmlAttribute("source", ""));
                    break;
                case XsdElement.Attribute:
                    list.Add(new BigXmlAttribute("default", ""));
                    list.Add(new BigXmlAttribute("fixed", ""));
                    list.Add(new BigXmlAttribute("form", ""));
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("name", ""));
                    list.Add(new BigXmlAttribute("ref", ""));
                    list.Add(new BigXmlAttribute("type", ""));
                    list.Add(new BigXmlAttribute("use", ""));
                    break;
                case XsdElement.AttributeGroup:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("name", ""));
                    list.Add(new BigXmlAttribute("ref", ""));
                    break;
                case XsdElement.ComplexContent:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("mixed", ""));
                    break;
                case XsdElement.ComplexType:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("name", ""));
                    list.Add(new BigXmlAttribute("abstract", ""));
                    list.Add(new BigXmlAttribute("mixed", ""));
                    list.Add(new BigXmlAttribute("block", ""));
                    list.Add(new BigXmlAttribute("final", ""));
                    break;
                case XsdElement.Documentation:
                    list.Add(new BigXmlAttribute("source", ""));
                    list.Add(new BigXmlAttribute("xml", "lang", "", "")); // ???
                    break;
                case XsdElement.Element:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("name", ""));
                    list.Add(new BigXmlAttribute("ref", ""));
                    list.Add(new BigXmlAttribute("type", ""));
                    list.Add(new BigXmlAttribute("substitutionGroup", ""));
                    list.Add(new BigXmlAttribute("default", ""));
                    list.Add(new BigXmlAttribute("fixed", ""));
                    list.Add(new BigXmlAttribute("form", ""));
                    list.Add(new BigXmlAttribute("maxOccurs", ""));
                    list.Add(new BigXmlAttribute("minOccurs", ""));
                    list.Add(new BigXmlAttribute("nillable", ""));
                    list.Add(new BigXmlAttribute("abstract", ""));
                    list.Add(new BigXmlAttribute("block", ""));
                    list.Add(new BigXmlAttribute("final", ""));
                    break;
                case XsdElement.Enumeration:
                    break;
                case XsdElement.Extension:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.Field:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.FractionDigits:
                    break;
                case XsdElement.Group:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("name", ""));
                    list.Add(new BigXmlAttribute("ref", ""));
                    list.Add(new BigXmlAttribute("maxOccurs", ""));
                    list.Add(new BigXmlAttribute("minOccurs", ""));
                    break;
                case XsdElement.Choice:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("maxOccurs", ""));
                    list.Add(new BigXmlAttribute("minOccurs", ""));
                    break;
                case XsdElement.Import:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("namespace", ""));
                    list.Add(new BigXmlAttribute("schemaLocation", ""));
                    break;
                case XsdElement.Include:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.Key:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.KeyRef:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.Length:
                    break;
                case XsdElement.List:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("itemType", ""));
                    break;
                case XsdElement.MaxExclusive:
                    break;
                case XsdElement.MaxInclusive:
                    break;
                case XsdElement.MaxLength:
                    break;
                case XsdElement.MinExclusive:
                    break;
                case XsdElement.MinInclusive:
                    break;
                case XsdElement.MinLength:
                    break;
                case XsdElement.Notation:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("system", ""));
                    break;
                case XsdElement.Pattern:
                    break;
                case XsdElement.Redefine:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.Restriction:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.Selector:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.Sequence:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("maxOccurs", ""));
                    list.Add(new BigXmlAttribute("minOccurs", ""));
                    break;
                case XsdElement.Schema:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("attributeFormDefault", ""));
                    list.Add(new BigXmlAttribute("elementFormDefault", ""));
                    list.Add(new BigXmlAttribute("blockDefault", ""));
                    list.Add(new BigXmlAttribute("finalDefault", ""));
                    list.Add(new BigXmlAttribute("targetNamespace", ""));
                    list.Add(new BigXmlAttribute("version", ""));
                    break;
                case XsdElement.SimpleContent:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.SimpleType:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("name", ""));
                    break;
                case XsdElement.TotalDigits:
                    break;
                case XsdElement.Union:
                    list.Add(new BigXmlAttribute("id", ""));
                    list.Add(new BigXmlAttribute("memberTypes", ""));
                    break;
                case XsdElement.Unique:
                    list.Add(new BigXmlAttribute("id", ""));
                    break;
                case XsdElement.WhiteSpace:
                    break;
            }

            return list;
        }
    }
}
